import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.*;
import java.util.Iterator;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
import java.util.*;

public class JsonHello {
     public static void main(String[] args) {
 
	JSONParser myParser = new JSONParser();
	BufferedReader br = null;
	
	try {
		br = new BufferedReader(new FileReader("C:\\Users\\Administrator\\Desktop\\research\\Yelp\\yelp_business.json"));
		String bizLine="";
		while((bizLine = br.readLine())!=null){
			Object obj = myParser.parse(bizLine);
 
			JSONObject jsonObject = (JSONObject) obj;
			String name = (String) jsonObject.get("name");
			//String category = (String)jsonObject.get("categories");
			//List catList = Arrays.asList(category);
			//if(catList.contains("Restaurants")) 
			ArrayList<String> list = (ArrayList)jsonObject.get("categories");
			// Get all restaurants in business file
			if(list.contains("Restaurants")) System.out.println(name);
		}
 /*
		// loop array
		JSONArray msg = (JSONArray) jsonObject.get("messages");
		Iterator<String> iterator = msg.iterator();
		while (iterator.hasNext()) {
			System.out.println(iterator.next());
		}
 */
	} catch (FileNotFoundException e) {
		e.printStackTrace();
	} catch (IOException e) {
		e.printStackTrace();
	} catch (ParseException e) {
		e.printStackTrace();
	}
 
     }
 
}